home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Utilities / System / FKey / FKeys / InvisWin / InvisiWin.c next >
C/C++ Source or Header  |  1989-08-08  |  2KB  |  98 lines

  1. /*
  2.     InvisiWin FKey #7  --  Version 1.1  --  Nov 28, 1988
  3.     
  4.     Copyright (c) 1988-89 by Neal E. Trautman & Josh Pritikin
  5.     
  6.     'ShareWare' -- Please send $3 contribution to:
  7.         Neal Trautman
  8.         1701 S.W. 42nd Street
  9.         Fargo, ND 58103
  10.     
  11.     and a $.20 contribution to:    ( <- just kidding)
  12.         Josh Pritikin
  13.         1404 Greenworth Place
  14.         Santa Barbara, CA 93108
  15.     
  16.     This FKey makes the content region of the front window transparent.
  17.         (If it is already transparent, the content region returns)
  18.     
  19.     8.7.89 - Updated so that option flips all the windows in an application
  20.             by Josh Pritikin.  GEnie J.Pritikin.
  21.             
  22.             This modification is real useful if you use multifinder because
  23.             you can hide all of the windows in an application, to speed
  24.             updating.  I also make a quickey combination (control-space) to
  25.             make it easier to run the fkey.  Who needs Sys 7.0 with it's
  26.             layer hiding abilities?
  27. */
  28.  
  29. main()
  30. {
  31.     register WindowPeek    win;
  32.     register RgnHandle    cont;
  33.     register long    keys[4];
  34.     register Boolean    wasVis;
  35.     
  36.     win = (WindowPeek)FrontWindow();
  37.     if (!win) {
  38.         SysBeep(1);
  39.         return;
  40.     }
  41.     
  42.     cont = win->contRgn;
  43.     
  44.     GetKeys(keys);
  45.     if ((keys[1] >> 3) & 0x01) {
  46.         if (EmptyRgn(cont)) {
  47.             wasVis = false;
  48.             WinVis(win);
  49.         } else {
  50.             wasVis = true;
  51.             WinInv(win);
  52.         }
  53.         win = win->nextWindow;
  54.         
  55.         while(win != 0l) {
  56.             if (!win->visible) goto nxt;
  57.             
  58.             cont = win->contRgn;
  59.             if (EmptyRgn(cont)) {
  60.                 if (!wasVis) {
  61.                     WinVis(win);
  62.                 }
  63.             } else {
  64.                 if (wasVis) {
  65.                     WinInv(win);
  66.                 }
  67.             }
  68.             
  69.             nxt:
  70.             win = win->nextWindow;
  71.         }
  72.     } else {
  73.         if (EmptyRgn(cont))    WinVis(win);
  74.         else                        WinInv(win);
  75.     }
  76. }
  77.  
  78. WinVis(win)
  79. WindowPeek    win;
  80. {
  81.     ShowHide(win, false);
  82.     ShowHide(win, true);
  83. }
  84.  
  85. WinInv(win)
  86. WindowPeek    win;
  87. {
  88.     register RgnHandle    cont;
  89.     
  90.     cont = win->contRgn;
  91.     win->contRgn = NewRgn();
  92.     DiffRgn(win->strucRgn, cont, win->strucRgn);
  93.     CalcVisBehind(win, cont);
  94.     PaintBehind(win, cont);
  95.     DisposeRgn(cont);
  96. }
  97.  
  98.